﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSharpAlgorithm
{
    class WindowsBreak
    {
        public WindowsBreak()
        {
            int testCount = Int32.Parse(TestConsole.ReadLine());
            for (int testCase = 1; testCase <= testCount; testCase++)
            {
                string[] input = TestConsole.ReadLine().Split(' ');

                int windowsCount = Int32.Parse(input[0]);
                int badBoy = Int32.Parse(input[1]);
                int goodBoy = Int32.Parse(input[2]);
                int helper = Int32.Parse(input[3]);

                double totalCase = (double)Math.Pow(windowsCount, badBoy + goodBoy);
                //강화된 창문이 안 깨지는 경우의 수
                double caseCountHelp = GetCaseCount(windowsCount, badBoy, goodBoy, true);
                //일반 창문이 안 깨지는 경우의 수
                double caseCountNormal = GetCaseCount(windowsCount, badBoy, goodBoy, false);
                

                Console.WriteLine("Case #" + testCase + ": ");
            }
        }
        double GetCaseCount(int windowsCount, int badBoy, int goodBoy, bool help)
        {
            double caseCount = 0;
            for (int a = 0; a <= badBoy; a++)
            {
                int start = help ? Math.Max(0, a - 1) : a;
                for (int b = start; b <= goodBoy; b++)
                {
                    int otherWindows = windowsCount - 1;
                    double nowCase = (double)Math.Pow(windowsCount - 1, (badBoy - a) + (goodBoy - b));
                    caseCount += nowCase;
                }
            }
            return caseCount;
        }
        private long Factorial(int start, int end)
        {
            if (start == 0 && end == 0) return 1;
            if (end > start) return 0;
            long result = start;
            for (int i = start - 1; i >= end; i--)
            {
                result *= i;
            }
            return result;
        }
    }
}
